package com.artpri.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.artpri.model.AdNews;
import com.artpri.model.AdPicture;
import com.artpri.service.IndexPagePictureService;

/**
 * 所有首页页面信息的读取（首页图片信息，首页商品信息）
 * 
 * @author 王校兵
 * @date 2016-7-19
 * @version 1.0
 * */
@Controller
public class IndexPagePictureAtion extends BaseAction {

	/**
	 * 序列化信息
	 */
	private static final long serialVersionUID = 7172575675753065794L;

	@Autowired
	private IndexPagePictureService indexPagePictureService;

	/**
	 * 要取到的数据的起始的位置编码
	 * */
	private String fromPosition;

	/**
	 * 页面代码
	 * */
	private String page;

	/**
	 * 从数据库中取到的指定页面的广告位图片等信息集合
	 * */
	private List<AdPicture> picture;

	/**
	 * 从数据库中取到的指定页面的商品的信息集合（包括商品详情等）
	 * */
	private List pictureAndProduct;
	
	/**
	 * 从数据库中取到的页面上的指定未知的新闻信息
	 * */
	private List<AdNews> news;

	/**
	 * 要取到的产品或广告数据的终止的位置编码
	 * */
	private String toPosition;
	
	/**
	 * 要取到的新闻数据的终止位置信息
	 * */
	private String newsToPosition;

	/**
	 * @return the fromPosition
	 */
	public String getFromPosition() {
		return fromPosition;
	}

	/**
	 * @return the news
	 */
	public List<AdNews> getNews() {
		return news;
	}

	/**
	 * @return the newsToPosition
	 */
	public String getNewsToPosition() {
		return newsToPosition;
	}

	/**
	 * @return the page
	 */
	public String getPage() {
		return page;
	}

	/**
	 * @return the picture
	 */
	public List<AdPicture> getPicture() {
		return picture;
	}

	/**
	 * @return the pictureAndProduct
	 */
	public List getPictureAndProduct() {
		return pictureAndProduct;
	}

	/**
	 * @return the toPosition
	 */
	public String getToPosition() {
		return toPosition;
	}

	/**
	 * 获取首页新闻等上方的图片（采用下拉位置判断方式）
	 * 
	 * @param page
	 *            页面代码
	 * @param position
	 *            页面位置信息
	 * */
	public String indexImage() {

		// 获取数据库中的picture
		picture = indexPagePictureService.getIndexPicture(page, fromPosition,
				toPosition);
		
		news = indexPagePictureService.getAppointNews(page, fromPosition, newsToPosition);
		
		return SUCCESS;
	}

	/**
	 * 获取首页的图片和商品（采用下拉位置判断方式）
	 * */
	public String indexImageAndProduct() {
		
		pictureAndProduct = indexPagePictureService.getIndexPictureAndProduct(
				page, fromPosition, toPosition);
		
		news = indexPagePictureService.getAppointNews(page, fromPosition, newsToPosition);
		return SUCCESS;
	}

	/**
	 * @param fromPosition
	 *            the fromPosition to set
	 */
	public void setFromPosition(String fromPosition) {
		this.fromPosition = fromPosition;
	}

	/**
	 * @param news the news to set
	 */
	public void setNews(List<AdNews> news) {
		this.news = news;
	}

	/**
	 * @param newsToPosition the newsToPosition to set
	 */
	public void setNewsToPosition(String newsToPosition) {
		this.newsToPosition = newsToPosition;
	}

	/**
	 * @param page
	 *            the page to set
	 */
	public void setPage(String page) {
		this.page = page;
	}

	/**
	 * @param picture
	 *            the picture to set
	 */
	public void setPicture(List<AdPicture> picture) {
		this.picture = picture;
	}

	/**
	 * @param pictureAndProduct
	 *            the pictureAndProduct to set
	 */
	public void setPictureAndProduct(List pictureAndProduct) {
		this.pictureAndProduct = pictureAndProduct;
	}

	/**
	 * @param toPosition
	 *            the toPosition to set
	 */
	public void setToPosition(String toPosition) {
		this.toPosition = toPosition;
	}

}
